← Index
NYTProf Performance Profile   
For /usr/share/koha/opac/cgi-bin/opac/opac-search.pl
  Run on Tue Oct 15 11:58:52 2013
Reported on Tue Oct 15 12:02:20 2013

Filename(eval 1017)[/usr/share/perl5/Date/Parse.pm:223]
StatementsExecuted 7 statements in 151µs
Eval Invoked At/usr/share/perl5/Date/Parse.pm line 223
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
0000s0sDate::Parse::::__ANON__[:146]Date::Parse::__ANON__[:146]
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1157µs my %month = map { lc $_ } %$mon_ref;
2132µs110µs my $daypat = join("|", map { lc $_ } reverse sort keys %$day_ref);
# spent 10µs making 1 call to Date::Parse::CORE:sort
3114µs16µs my $monpat = join("|", reverse sort keys %month);
# spent 6µs making 1 call to Date::Parse::CORE:sort
4116µs14µs my $sufpat = join("|", reverse sort map { lc $_ } @$suf_ref);
# spent 4µs making 1 call to Date::Parse::CORE:sort
5
612µs my %ampm = (
7 'a' => 0, # AM
8 'p' => 12, # PM
9 );
10
111500ns my($AM, $PM) = (0,12);
12
13sub {
14
15 my $dtstr = lc shift;
16 my $merid = 24;
17
18 my($year,$month,$day,$hh,$mm,$ss,$zone,$dst,$frac);
19
20 $zone = tz_offset(shift) if @_;
21
22 1 while $dtstr =~ s#\([^\(\)]*\)# #o;
23
24 $dtstr =~ s#(\A|\n|\Z)# #sog;
25
26 # ignore day names
27 $dtstr =~ s#([\d\w\s])[\.\,]\s#$1 #sog;
28 $dtstr =~ s/,/ /g;
29 $dtstr =~ s#($daypat)\s*(den\s)?\b# #o;
30 # Time: 12:00 or 12:00:00 with optional am/pm
31
32 return unless $dtstr =~ /\S/;
33
34 if ($dtstr =~ s/\s(\d{4})([-:]?)(\d\d?)\2(\d\d?)(?:[-Tt ](\d\d?)(?:([-:]?)(\d\d?)(?:\6(\d\d?)(?:[.,](\d+))?)?)?)?(?=\D)/ /) {
35 ($year,$month,$day,$hh,$mm,$ss,$frac) = ($1,$3-1,$4,$5,$7,$8,$9);
36 }
37
38 unless (defined $hh) {
39 if ($dtstr =~ s#[:\s](\d\d?):(\d\d?)(:(\d\d?)(?:\.\d+)?)?(z)?\s*(?:([ap])\.?m?\.?)?\s# #o) {
40 ($hh,$mm,$ss) = ($1,$2,$4);
41 $zone = 0 if $5;
42 $merid = $ampm{$6} if $6;
43 }
44
45 # Time: 12 am
46
47 elsif ($dtstr =~ s#\s(\d\d?)\s*([ap])\.?m?\.?\s# #o) {
48 ($hh,$mm,$ss) = ($1,0,0);
49 $merid = $ampm{$2};
50 }
51 }
52
53 if (defined $hh and $hh <= 12 and $dtstr =~ s# ([ap])\.?m?\.?\s# #o) {
54 $merid = $ampm{$1};
55 }
56
57
58 unless (defined $year) {
59 # Date: 12-June-96 (using - . or /)
60
61 if ($dtstr =~ s#\s(\d\d?)([\-\./])($monpat)(\2(\d\d+))?\s# #o) {
62 ($month,$day) = ($month{$3},$1);
63 $year = $5 if $5;
64 }
65
66 # Date: 12-12-96 (using '-', '.' or '/' )
67
68 elsif ($dtstr =~ s#\s(\d+)([\-\./])(\d\d?)(\2(\d+))?\s# #o) {
69 ($month,$day) = ($1 - 1,$3);
70
71 if ($5) {
72 $year = $5;
73 # Possible match for 1995-01-24 (short mainframe date format);
74 ($year,$month,$day) = ($1, $3 - 1, $5) if $month > 12;
75 return if length($year) > 2 and $year < 1901;
76 }
77 }
78 elsif ($dtstr =~ s#\s(\d+)\s*($sufpat)?\s*($monpat)# #o) {
79 ($month,$day) = ($month{$3},$1);
80 }
81 elsif ($dtstr =~ s#($monpat)\s*(\d+)\s*($sufpat)?\s# #o) {
82 ($month,$day) = ($month{$1},$2);
83 }
84 elsif ($dtstr =~ s#($monpat)([\/-])(\d+)[\/-]# #o) {
85 ($month,$day) = ($month{$1},$3);
86 }
87
88 # Date: 961212
89
90 elsif ($dtstr =~ s#\s(\d\d)(\d\d)(\d\d)\s# #o) {
91 ($year,$month,$day) = ($1,$2-1,$3);
92 }
93
94 $year = $1 if !defined($year) and $dtstr =~ s#\s(\d{2}(\d{2})?)[\s\.,]# #o;
95
96 }
97
98 # Zone
99
100 $dst = 1 if $dtstr =~ s#\bdst\b##o;
101
102 if ($dtstr =~ s#\s"?([a-z]{3,4})(dst|\d+[a-z]*|_[a-z]+)?"?\s# #o) {
103 $dst = 1 if $2 and $2 eq 'dst';
104 $zone = tz_offset($1);
105 return unless defined $zone;
106 }
107 elsif ($dtstr =~ s#\s([a-z]{3,4})?([\-\+]?)-?(\d\d?):?(\d\d)?(00)?\s# #o) {
108 my $m = defined($4) ? "$2$4" : 0;
109 my $h = "$2$3";
110 $zone = defined($1) ? tz_offset($1) : 0;
111 return unless defined $zone;
112 $zone += 60 * ($m + (60 * $h));
113 }
114
115 if ($dtstr =~ /\S/) {
116 # now for some dumb dates
117 if ($dtstr =~ s/^\s*(ut?|z)\s*$//) {
118 $zone = 0;
119 }
120 elsif ($dtstr =~ s#\s([a-z]{3,4})?([\-\+]?)-?(\d\d?)(\d\d)?(00)?\s# #o) {
121 my $m = defined($4) ? "$2$4" : 0;
122 my $h = "$2$3";
123 $zone = defined($1) ? tz_offset($1) : 0;
124 return unless defined $zone;
125 $zone += 60 * ($m + (60 * $h));
126 }
127
128 return if $dtstr =~ /\S/o;
129 }
130
131 if (defined $hh) {
132 if ($hh == 12) {
133 $hh = 0 if $merid == $AM;
134 }
135 elsif ($merid == $PM) {
136 $hh += 12;
137 }
138 }
139
140 $year -= 1900 if defined $year && $year > 1900;
141
142 $zone += 3600 if defined $zone && $dst;
143 $ss += "0.$frac" if $frac;
144
145 return ($ss,$mm,$hh,$day,$month,$year,$zone);
146}
147
148129µs;